Skip to content

Self-contained Colab notebook for the digit tutorial (POC) - #4

Draft
cmanjah wants to merge 1 commit into
mainfrom
feat/colab-notebook-poc
Draft

cmanjah wants to merge 1 commit into
mainfrom
feat/colab-notebook-poc

Conversation

@cmanjah

@cmanjah cmanjah commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Proof-of-concept for lightweight, self-contained tutorial notebooks that run from the tutorial webpage and Google Colab — starting with the digit domain-adaptation example. One example now; the pattern rolls out to the rest one notebook at a time.

What this does

  • Self-contained notebook. Reworks others/image_classification/digit_domain_adaptation/tutorial.ipynb to inline its config and model build and drop every sibling import (config.py, model.py, configs/tutorial.yaml). Colab loads only the .ipynb, so it previously could not run; now it can.
  • Clean Colab setup. Replaces the old git clone … cd examples/digits_dann cell with pip install "pykale[image]" matplotlib (a no-op off Colab).
  • Friendly + lightweight. Plain-language sections (what domain adaptation is, source vs. target, what DANN does); ~3 epochs on a fifth of the data → a few minutes on a free CPU. Points at the full main.py for real numbers.
  • Site wiring. tutorial_actions now points Colab / Download-Notebook at each example's own tutorial.ipynb, and conf.py enables those buttons per-tutorial when the file exists. Examples without a notebook keep a disabled button with a reason — so this is additive and the rollout is incremental.

Publish target

Each example's notebook lives in its own folder (<example>/tutorial.ipynb), beside the narrative and example code.

Verification

  • Executed the committed notebook headless end-to-end: no errors, USPS (target) accuracy ≈ 0.73, MNIST ≈ 0.94. Committed with no stale outputs.
  • 96 tests pass; validate and the strict -W --keep-going build are green.

Notes

  • The Colab button resolves once this is on main (URL is blob/main/…).
  • The gallery narrative (plot_*.py) is unchanged; whether to converge on a single source (narrative ⇄ notebook) to avoid drift is a follow-up decision before the full rollout.

Draft for review.

Rework the digit domain-adaptation tutorial.ipynb into a self-contained, lightweight
notebook that runs top-to-bottom on a free CPU and opens directly in Google Colab:

- Inline the config and model build; no sibling imports (config.py/model.py/configs),
  so Colab -- which loads only the .ipynb -- can run it.
- Clean Colab install cell: pip install "pykale[image]" matplotlib, no-op elsewhere.
- Plain-language narrative; ~3 epochs on a data subset (a few minutes on CPU).
- Verified end-to-end headless: runs with no errors, USPS target accuracy ~0.73.

Wire the site to it: tutorial_actions points Colab/Notebook at each example's own
tutorial.ipynb and enables the buttons per-tutorial when that file exists (conf.py
checks for it), so the rollout to the other examples is one notebook at a time.

96 tests pass; validate and the strict -W build are green.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant